home *** CD-ROM | disk | FTP | other *** search
/ Best of www.BestZips.com (Collector's Edition) / Best of WWW.BESTZIPS.COM Collector's Edition (JCSM Shareware) (JCS Marketing).ISO / tutorial / adatu311.zip / ONECHAR.C < prev    next >
C/C++ Source or Header  |  1996-01-10  |  1KB  |  34 lines

  1. /*
  2. ONECHAR.C   Ver. 3.11   10-JAN-1996
  3.  
  4. SOFTWARE INNOVATIONS TECHNOLOGY      http://members.aol.com/AdaTutor
  5. 1083 MANDARIN DR NE                  ftp://members.aol.com/AdaTutor
  6. PALM BAY FL 32905-4706
  7.                                      johnherro@aol.com
  8. (407) 951-0233                       john.herro%374-38-2@satlink.oau.org
  9.  
  10. This file is for use with UNIX.ADA.  It is a Unix System V routine to allow
  11. the capture and return of one character from the terminal.
  12.  
  13. This program was written by Dave Hill, 7549 Wynford Street, Salt Lake City, UT
  14. 84121.  Software Innovations Technology is grateful to Mr. Hill for permission
  15. to include ONECHAR.C with ADA-TUTR.
  16. */
  17.  
  18. #include <stdio.h>
  19. #include <termio.h>
  20. char onechar()
  21. {
  22.     static struct termio newsets, oldsets;
  23.     char c;
  24.     ioctl(fileno(stdin), TCGETA, &newsets);
  25.     ioctl(fileno(stdin), TCGETA, &oldsets); /* used by cooked */
  26.     newsets.c_cc[4] = '\001';
  27.     newsets.c_cc[5] = '\0';
  28.     newsets.c_lflag &= ~ (ICANON);
  29.     ioctl(fileno(stdin), TCSETAF, &newsets);
  30.     c = getchar();
  31.     ioctl(fileno(stdin), TCSETAF, &oldsets);
  32.     return (c);
  33. }
  34.